package com.atguigu.lease.web.admin.custom.converter;


import com.atguigu.lease.model.enums.ItemType;


import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

//@Component 手写的转换类
public class StringToItemtypeConverter implements Converter<String, ItemType> {

    //为什么要转换 因为type = 1 不能直接转换为Itemtype type

    public ItemType convert(String code) {
        if(code.equals("1")){
            return ItemType.APARTMENT;
        }else{
            return ItemType.ROOM;
        }
    }
}
